import OpenGL.GL as gl
import numpy as np

class VertexBufferObject:
    def __init__(self, data: np.ndarray, flags: int = 
                 gl.GL_DYNAMIC_STORAGE_BIT) -> None:
        vbo = np.empty(1, gl.GLuint)
        gl.glCreateBuffers(1, vbo)
        self.vbo_id = vbo[0]
        gl.glNamedBufferStorage(self.vbo_id, data.nbytes, data, flags)

    def delete(self) -> None:
        if gl.glIsBuffer(self.vbo_id):
            gl.glDeleteBuffers(1, self.vbo_id)

    def setData(self, offset:int, data: np.ndarray) -> None:
        gl.glNamedBufferSubData(self.vbo_id, offset, data.nbytes, data)
        